<table class="table-content" cellspacing="0" cellpadding="0" >
    <col width="50px" />
    <col width="30px" />
    <col width="250px" />
    <col width="250px" />
    <col width="150px" />
    <col width="200px" />
    <col width="200px" />
    <tr class="table-header">
        <!--<th class="center" width="20px;">
        <input type="checkbox" name="test" onchange="checkAll()" id="checkAll"/>
        </th>-->
        <th>Comment</th>
        <th>Edit</th>
        <th>Tên</th>
        <th>Địa chỉ</th>
        <th>Tel</th>
        <th>Email</th>
        <th>Website</th>
    </tr>
    <?php foreach($this->result as $key=>$value){?>
        <tr>
            <!--<td class="center" width="20px;"><input type="checkbox" name="merchant_selected[]" value="<?php echo $value->place_id;?>"/></td>-->
            <td><a class="comment-button" href="/place/place-comment/index?place_id=<?php echo $value->place_id;?>"></a></td>
            <td><a class="edit-button" href="/place/place-edit/index?place_id=<?php echo $value->place_id;?>"></a></td>
            <td class="container"><div><?php echo $value->name ?></div></td>
            <td class="container"><div><?php echo $value->address ?></div></td>
            <td class="container"><div><?php echo $value->phone ?></div></td>
            <td class="container"><div><?php echo $value->mail ?></div></td>
            <td class="container"><div><?php echo $value->website ?></div></td>
            
        </tr>
    <?php } ?>
</table>
<div class="pagging">
    <a class="pagging-first" id="pagging-search-first" href="#" onclick="loadSearchTable(1); return false;"></a>
    <a class="pagging-pre" id="pagging-search-pre" href="#"></a>
    <input class="pagging-seach" id="pagging-seach-search" value="<?php echo $this->page;?>"/><div class="pagging-info">of <?php echo $this->pageNumber; ?></div> 
    <a class="pagging-next" id="pagging-search-next" href="#"></a>
    <a class="pagging-last" id="pagging-search-last" href="#" onclick="loadSearchTable(<?php echo $this->pageNumber;?>); return false;" ></a>
</div>
<script>
    function loadSearchTable(page){
        merchant_name = $.trim('<?php echo $this->name;?>');
        merchant_address = '';
        merchant_address = $.trim('<?php echo $this->address;?>');
        merchant_tel = '';
        merchant_tel = $.trim('<?php echo $this->phone;?>');
        merchant_website = '';
        merchant_website = $.trim('<?php echo $this->website;?>');
        url = '/place/merchant-place/search-place' + 
                    "?merchant_name="+encodeURIComponent(merchant_name)+
                    "&address="+encodeURIComponent(merchant_address)+
                    "&tel="+encodeURIComponent(merchant_tel)+
                    "&website="+encodeURIComponent(merchant_website)+
                    "&page="+page;
        $("#pagging-seach-search").val(page);
        $("#table-place").load(url);
    }

    
    $(document).ready(function(){
        merchant_name = $.trim('<?php echo $this->name;?>');
        merchant_address = '';
        merchant_address = $.trim('<?php echo $this->address;?>');
        merchant_tel = '';
        merchant_tel = $.trim('<?php echo $this->phone;?>');
        merchant_email = '';
        merchant_email = $.trim('<?php echo $this->website;?>');
        $("#pagging-search-pre").click(function(e){
            page = parseInt($("#pagging-seach-search").val());
            prev_page = page - 1;
            if(prev_page < 1){
                return false;
            }else{
                $("#pagging-seach-search").val(prev_page);
                
                if(prev_page > 0){
                    //$("#merchant-table").load('/admin/merchant/load' + "?page="+prev_page);
                    url = '/place/merchant-place/search-place' + 
                            "?merchant_name="+encodeURIComponent(merchant_name)+
                            "&address="+encodeURIComponent(merchant_address)+
                            "&tel="+encodeURIComponent(merchant_tel)+
                            "&website="+encodeURIComponent(merchant_website)+
                            "&page="+prev_page;
                    $("#table-place").load(url);
                    return false;
                }
                
            }
        });
        
        $("#pagging-search-next").click(function(e){
            page = parseInt($("#pagging-seach-search").val());
            next_page = page + 1;
            if(next_page > <?php echo $this->pageNumber?>){
                return false;
            }else{
                
                $("#pagging-seach-search").val(next_page);
                url = '/place/merchant-place/search-place' + 
                            "?merchant_name="+encodeURIComponent(merchant_name)+
                            "&address="+encodeURIComponent(merchant_address)+
                            "&tel="+encodeURIComponent(merchant_tel)+
                            "&website="+encodeURIComponent(merchant_website)+
                            "&page="+next_page;
                $("#table-place").load(url);
                return false;
            }
        });
        
        $("#pagging-seach-search").keyup(function(event){
            if(event.keyCode == 13){
                page = $("#pagging-seach-search").val();
                if(page > 0 && page <= <?php echo $this->pageNumber?>){
                    $("#pagging-seach-search").val(page);
                    url = '/place/merchant-place/search-place' + 
                            "?merchant_name="+encodeURIComponent(merchant_name)+
                            "&address="+encodeURIComponent(merchant_address)+
                            "&tel="+encodeURIComponent(merchant_tel)+
                            "&website="+encodeURIComponent(merchant_website)+

                            "&page="+page;
                    $("#table-place").load(url);
                }else if(page <= 0){
                    url = '/place/merchant-place/search-place' + 
                            "?merchant_name="+encodeURIComponent(merchant_name)+
                            "&address="+encodeURIComponent(merchant_address)+
                            "&tel="+encodeURIComponent(merchant_tel)+
                            "&website="+encodeURIComponent(merchant_website);
                    $("#table-place").load(url);
                    $("#pagging-seach-search").val(1);
                }else if(page > <?php echo $this->pageNumber?>){
                    $("#pagging-seach-search").val(<?php echo $this->pageNumber;?>);
                    url = '/place/merchant-place/search-place' + 
                            "?merchant_name="+encodeURIComponent(merchant_name)+
                            "&address="+encodeURIComponent(merchant_address)+
                            "&tel="+encodeURIComponent(merchant_tel)+
                            "&website="+encodeURIComponent(merchant_website)+
                            "&page="+<?php echo $this->pageNumber;?>;
                    $("#table-place").load(url);
                }
            }
        });
    });
</script>